package databean;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

import databean.mydata;
import databean.Compose;

public class ComposeBean {
	public ComposeBean() {
		
	}
	public ArrayList<Compose> getCompose(){
		ArrayList<Compose> arr = new ArrayList<Compose>();
		mydata db = new mydata();
		System.out.println("testcompose\n");
		ResultSet rs = null;
		try {
			String sql = "select * from compose";
			rs = db.myquery(sql);
			while(rs.next()){
				int composeId = rs.getInt("composeId");
				String product1 = rs.getString("product1");
				double ratio1 = rs.getDouble("ratio1");
				String  product2 = rs.getString("product2");
				double ratio2 = rs.getDouble("ratio2");
				String  product3 = rs.getString("product3");
				double ratio3 = rs.getDouble("ratio3");
				String  product4 = rs.getString("product4");
				double ratio4 = rs.getDouble("ratio4");
				Compose comp = new Compose(composeId,product1,ratio1,product2,ratio2,product3,ratio3,product4,ratio4);
				arr.add(comp);
			}
			System.out.println(arr.size());
			rs.close();
			db.closesql();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return arr;
	}
}
